package guda.shop.cms.manager.impl;

import guda.shop.cms.dao.ShopMemberAddressDao;
import guda.shop.cms.entity.Cart;
import guda.shop.cms.entity.ShopMemberAddress;
import guda.shop.cms.manager.CartMng;
import guda.shop.cms.manager.ShopMemberAddressMng;
import guda.shop.cms.manager.ShopMemberMng;
import guda.shop.common.hibernate3.Updater;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class ShopMemberAddressMngImpl
        implements ShopMemberAddressMng {
    private ShopMemberAddressDao shopMemberAddressDao;
    private ShopMemberMng shopMemberMng;
    private CartMng cartMng;

    @Transactional(readOnly = true)
    public List<ShopMemberAddress> getList(Long paramLong) {
        return this.shopMemberAddressDao.getList(paramLong);
    }

    public ShopMemberAddress findByMemberDefault(Long paramLong, Boolean paramBoolean) {
        List localList = this.shopMemberAddressDao.findByMemberDefault(paramLong, paramBoolean);
        if (localList.size() >= 1)
            return (ShopMemberAddress) localList.get(0);
        return null;
    }

    public List<ShopMemberAddress> findByMemberId(Long paramLong) {
        return this.shopMemberAddressDao.findByMemberDefault(paramLong, null);
    }

    @Transactional(readOnly = true)
    public ShopMemberAddress findById(Long paramLong) {
        ShopMemberAddress localShopMemberAddress = this.shopMemberAddressDao.findById(paramLong);
        return localShopMemberAddress;
    }

    public ShopMemberAddress save(ShopMemberAddress paramShopMemberAddress) {
        return this.shopMemberAddressDao.save(paramShopMemberAddress);
    }

    public ShopMemberAddress updateByUpdater(ShopMemberAddress paramShopMemberAddress) {
        Updater localUpdater = new Updater(paramShopMemberAddress);
        return this.shopMemberAddressDao.updateByUpdater(localUpdater);
    }

    public ShopMemberAddress deleteById(Long paramLong1, Long paramLong2) {
        Cart localCart = this.cartMng.findById(paramLong2);
        ShopMemberAddress localShopMemberAddress = this.shopMemberAddressDao.deleteById(paramLong1);
        return localShopMemberAddress;
    }

    @Autowired
    public void setDao(ShopMemberAddressDao paramShopMemberAddressDao) {
        this.shopMemberAddressDao = paramShopMemberAddressDao;
    }

    @Autowired
    public void setShopMemberMng(ShopMemberMng paramShopMemberMng) {
        this.shopMemberMng = paramShopMemberMng;
    }

    @Autowired
    public void setCartMng(CartMng paramCartMng) {
        this.cartMng = paramCartMng;
    }
}

